﻿@model Wicresoft.SelfService.DAO.OS
@{
    Layout = null;
}
<script type="text/javascript">
    $(function () {

        var flag=false;
       
        $("#createBtn").click(function () {
            var OSName = $("#OSName").val();
            if (OSName == "") {
                alert("系统名称不能为空！");
                flag=false; 
            }
            else
            {
                $.post("@Url.Action("SearchByOSName", "OSMaintain")", $("#OSForm").serialize(), 
                function(data){           
                if(data == "true"){
                   alert("该选择分类已存在!");
                   flag=false;
                }
                else{
                    flag=true;
                }
                });
            }
            
            if (flag) {
                $.post("@Url.Action("CreateOS", "OSMaintain")", $("#OSForm").serialize(), 
                function(data){           
                if(data == "true"){
                    alert("创建成功");
                    $("#OSName").val("");
                    location.reload();
                }
                else{
                    alert("创建失败");
                }
                });
             }

        });

    });
</script>
<div class="right_title">添加操作系统</div>
<div class="right_box_top ui-icons">
</div>
<div class="right_box_bg">
    <div class="right_box">
        <div style="padding-bottom: 20px;">
            @using (Html.BeginForm("CreateOS", "OSMaintain", FormMethod.Post, new { @id = "OSForm" }))
            {
                <table style="width:100%;">
                    <tbody>
                        <tr>
                            <th align="right" style="width: 20%;">
                               <span>系统名称：</span>
                            </th>
                            <td align="left" style="width: 20%;">
                                @Html.EditorFor(model => model.OSName, new { id = "OSName" })
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <th align="left" style="width: 20%;">
                                
                            </th>
                            <td align="left">
                                <input class="Button1 ui-icons" type="button" id="createBtn" value="创建" style="margin-left: 45px; margin-top: 20px;" />
                            </td>
                            <td></td>
                        </tr>
                    </tbody>
                </table>
            }
        </div>
    </div>
</div>
<div class="right_box_down ui-icons">
</div>
